import { PureComponent } from 'react';
import moment from 'moment';
import {
    Row,
    Col,
    Form,
    Input,
    Select,
    Modal,
    Cascader,
    DatePicker
} from 'antd';
const FormItem = Form.Item;
const { Option } = Select;
import { dicTextByCodePcode,dicListByPcode } from '@/utils/dictionary'


@Form.create()
class CreateForm extends PureComponent {

	constructor(props) {
	    super(props);
	    this.state = {

	    }
	}


	okHandle = () => {
		const { form,handleAdd } = this.props;

	    form.validateFields((err, fieldsValue) => {
		        if (err) return;
		        form.resetFields();
			   	if(fieldsValue.a3201) {
			   				fieldsValue.a3201 = moment(fieldsValue.a3201._d).format("YYYY-MM-DD");
			   			}
			   	if(fieldsValue.a3204) {
			   				fieldsValue.a3204 = moment(fieldsValue.a3204._d).format("YYYY-MM-DD");
			   			}
			    handleAdd(fieldsValue,'CurriculumInfo');
		});
	};


	resetButton = () => {

	};

  render() {
    const {form: {getFieldDecorator}, modalVisibleByCurriculumInfo,handleModalVisible} = this.props;

return (
    <Modal
width={800}
destroyOnClose
title="添加履历信息"
visible={modalVisibleByCurriculumInfo}
onOk={this.okHandle}
onCancel={() => handleModalVisible(false,"CurriculumInfo")}
afterClose={() => this.resetButton()}
>
<Form  layout="vertical">
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>

		    <Col md={12} sm={24}>
		      <FormItem  label="所在单位">
		          {getFieldDecorator('a3207', {
		          rules: [{ required: false, message: '请输入1-10个字符',max: 10}],
		          })(<Input placeholder="1-10个字符"/>)}
		      </FormItem>
		    </Col>

		    <Col md={12} sm={24}>
		      <FormItem  label="起始日期">
		          {getFieldDecorator('a3201', {
		            rules: [{ required: false, message: '请选择'}],
		                })(<DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>)}
		            </FormItem>
		    </Col>

		</Row>
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>

		    <Col md={12} sm={24}>
		      <FormItem  label="截止日期">
		          {getFieldDecorator('a3204',{
		          	    })(<DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>)}
		          	</FormItem>
		    </Col>
		    <Col md={12} sm={24}>
		      <FormItem  label="身份或职务说明">
		          {getFieldDecorator('a3214', {
		          rules: [{ required: false, message: '请选择'}],
		          })(<Input placeholder="1-10个字符"/>)}
		      </FormItem>
		    </Col>

		</Row>

		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>

		<Col md={12} sm={24}>
		      <FormItem  label="履历类别">
		          {getFieldDecorator('a3221', {
		          rules: [{ required: false, message: '请选择'}],
		          })(
		          	<Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		          	  	{dicListByPcode('YT') != undefined?dicListByPcode('YT').map((item,index) => {
		          	  		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		          	  	}):null}
		          	  </Select>
		          )}
		      </FormItem>
		    </Col>

		    <Col md={12} sm={24}>
		      <FormItem  label="基层工作的标志">
		          {getFieldDecorator('a3212',{
		            rules: [{ required: false, message: '请选择！'}],
		          })(
		          	<Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		              {dicListByPcode('R1') != undefined?dicListByPcode('R1').map((item,index) => {
		                return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		              }):null}
		            </Select>
		          )}
		      </FormItem>
		    </Col>

		</Row>

		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>


		    <Col md={12} sm={24}>
		      <FormItem  label="履历说明">
		          {getFieldDecorator('a3224', {
		          rules: [{ required: false, message: '请选择'}],
		          })(
		            <Input placeholder="1-40个字符" />
		          )}
		      </FormItem>
		    </Col>


		</Row>

</Form>
</Modal>
);
  }

}

export default CreateForm;
